/*/**
 * Created by Lzhang on 2018/1/3.
 */
/*const reportApi = {
    'event': '/back/gamelog/event',
    'page': '/back/gamelog/page',
    'active': '/back/gamelog/active',
    'player': '/back/gamelog/player',
    
};
function getUuid() {// 获取uuid
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";

    var uuid = s.join("");
    return uuid;
}
function report(baseParams = {}, options = {}) {

    const reportType = options.reportType;
    delete options.reportType;
    
    let params =  {
        ...baseParams,
        actionTime: JSON.stringify(new Date().getTime()),
        ...options,
    };
    params = JSON.stringify(params);
    // alert(params, 'params===================');
    const encrypt = Encrypt(params);
    // console.log(encrypt)

    $.post(reportApi[reportType],{encrypt:`${encrypt}`,rootname:'w'},function(result){
        
        alert(result.description)

    })
}
function callback(options = {}) {
   // alert('进入native方法')
    //数据上报
  let baseParams = {
        appId:'3',
        appVersion: '1.0.0',
        cpId: '01',
        appChannel: '1',
        osType:'windows7',
        // deviceStyle:data,
        source: '4'
    };

    if (!window.external.GetSystemMTM){
        baseParams.deviceStyle = 'thinkPad';
    }else {
        baseParams.deviceStyle = window.external.GetSystemMTM();  //获取机型并上报
    }

    if (!window.external.GetSystemSN){
      if (!Cookies.get('uuid')){
          let uuid = getUuid();
          Cookies.set('uuid', uuid, {expires: 365 * 10});
          baseParams.deviceId = Cookies.get('uuid');
      }else {
          baseParams.deviceId = Cookies.get('uuid');
      }
    }else {
        baseParams.deviceId = window.external.GetSystemSN();  //获取deviceId上报
    }
    report(baseParams, options);
}

export { callback }*/


/**
 * Created by Lzhang on 2018/1/3.
 */
const reportApi = {
    'event': '/back/gamelog/event',
    'page': '/back/gamelog/page',
    'player': '/back/gamelog/player',
    //虎牙直播数据上报接口
    'events':'/back/gamelog/livelog/event',//事件上报
    'pages':'/back/gamelog/livelog/page',//页面上报
    'players':'/back/gamelog/livelog/live',//点击直播间上报
};
function report(baseParams = {}, options = {}) {
    const reportType = options.reportType;
    delete options.reportType;

    let params =  {
        ...baseParams,
        actionTime: JSON.stringify(new Date().getTime()),
        ...options,
    };
    params = JSON.stringify(params);
    // alert(params, 'params===================');
    const encrypt = Encrypt(params);

     console.log(encrypt+"转码")

    $.post(reportApi[reportType],{encrypt:`${encrypt}`,rootname:'w'},function(result){
        // alert('上报')
    })
}
function callback(options = {},data) {
   // alert('进入native方法')
    if(typeof data != "undefined"){
        res =  data;
        let data = JSON.parse(res);
        let baseParams = {
            vipId: data.vipId || '',
            lenovoId: data.vipId ? '' : data.lenovoId,
            deviceId: data.deviceId,
            // deviceId: data.vipId || data.lenovoId ? '' : data.deviceId,
            appId: 'lenovo-game',
            appVersion: data.appVersion,
            appChannel: data.appChannel,
            osType: data.osType,
            deviceStyle: data.deviceStyle,
            source: data.source
        };
        report(baseParams, options);
    }else{
        return function (res) {
            // alert(res)
            let data = JSON.parse(res);
            let baseParams = {
                vipId: data.vipId || '',
                lenovoId: data.vipId ? '' : data.lenovoId,
                deviceId: data.deviceId,
                appId: 'lenovo-game',
                appVersion: data.appVersion,
                appChannel: data.appChannel,
                osType: data.osType,
                deviceStyle: data.deviceStyle,
                source: data.source
            };
            report(baseParams, options);
        };
    }

    //测试数据上报是否成功
    let baseParams = {
        vipId:'1',
        cpId:'01',
        appId:'lenovo-game',
        appVersion: 1,
        appChannel: 1,
        osType: 1,
        deviceStyle: 1,
        source: 1
    };
    
    //report(baseParams, options);

}
export { callback }
